
package interfaz;

public class VentanaReagrupar extends javax.swing.JDialog {
    VentanaPrincipal vp;
    

    public VentanaReagrupar(java.awt.Frame parent, boolean modal, int ejercito) {
        super(parent, modal);
        this.setLocationRelativeTo(null);
        vp = (VentanaPrincipal)parent;
        initComponents();
        switch(ejercito)
        {
            case 2:
                jrbEjercito1.setEnabled(true);
                jrbEjercito2.setEnabled(false);
                jrbEjercito3.setEnabled(false);
                break;
            case 3:
                jrbEjercito1.setEnabled(true);
                jrbEjercito2.setEnabled(true);
                jrbEjercito3.setEnabled(false);
                break;
            default:
                jrbEjercito1.setEnabled(true);
                jrbEjercito2.setEnabled(true);
                jrbEjercito3.setEnabled(true);
                break;
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jrbEjercito1 = new javax.swing.JRadioButton();
        jrbEjercito2 = new javax.swing.JRadioButton();
        jrbEjercito3 = new javax.swing.JRadioButton();
        jbAceptar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("Gano la batalla!! Cuantos ejercitos desea pasar:");

        jrbEjercito1.setSelected(true);
        jrbEjercito1.setText("Un Ejercito");
        jrbEjercito1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbEjercito1ActionPerformed(evt);
            }
        });

        jrbEjercito2.setText("Dos Ejercitos");
        jrbEjercito2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbEjercito2ActionPerformed(evt);
            }
        });

        jrbEjercito3.setText("Tres Ejercitos");
        jrbEjercito3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbEjercito3ActionPerformed(evt);
            }
        });

        jbAceptar.setText("Aceptar");
        jbAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAceptarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jrbEjercito1)
                            .addComponent(jrbEjercito2)
                            .addComponent(jrbEjercito3))))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jbAceptar)
                .addGap(94, 94, 94))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jrbEjercito1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jrbEjercito2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jrbEjercito3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbAceptar)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jrbEjercito1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbEjercito1ActionPerformed
        this.jrbEjercito1.setSelected(true);
        this.jrbEjercito2.setSelected(false);
        this.jrbEjercito3.setSelected(false);
    }//GEN-LAST:event_jrbEjercito1ActionPerformed

    private void jrbEjercito2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbEjercito2ActionPerformed
        this.jrbEjercito1.setSelected(false);
        this.jrbEjercito2.setSelected(true);
        this.jrbEjercito3.setSelected(false);
    }//GEN-LAST:event_jrbEjercito2ActionPerformed

    private void jrbEjercito3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbEjercito3ActionPerformed
        this.jrbEjercito1.setSelected(false);
        this.jrbEjercito2.setSelected(false);
        this.jrbEjercito3.setSelected(true);
    }//GEN-LAST:event_jrbEjercito3ActionPerformed

    private void jbAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAceptarActionPerformed
        if(jrbEjercito1.isSelected()){
            vp.setEnvio(1);
        }else if(jrbEjercito2.isSelected()){
            vp.setEnvio(2);
        }else{
            vp.setEnvio(3);
        }
        this.dispose();
    }//GEN-LAST:event_jbAceptarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton jbAceptar;
    private javax.swing.JRadioButton jrbEjercito1;
    private javax.swing.JRadioButton jrbEjercito2;
    private javax.swing.JRadioButton jrbEjercito3;
    // End of variables declaration//GEN-END:variables

}
